<?php

	header("Content-Type: text/html;charset=utf-8");

	include("function/_nosql.php"); //
	include("function/function.php");

	include("_include.user.judge.php");

	$kboy_user = $_SESSION['kboy_user'];

	$kboy_userid = $_SESSION['kboy_userid'];

	$aid = chkstr(trim($_REQUEST['aid']));
	
	$kboy_shangche = chkstr(trim($_REQUEST['shangche']));
	if(empty($aid)){

		echo erro("参数错误");

	}

	if(!is_numeric($aid)){

		echo erro("参数错误");

	}

	if(getNewsNums("kboy_forum_active","id=$aid") <1){

		echo erro("参数错误");

	}

	if($kboy_shangche){
		$active_center = $kboy_shangche;
	}else{
		$active_center = getClassName("kboy_forum_active", "active_center","id = $aid");
	}
	
	
	$order_no = build_order_no();
	//$order_no = time();

	$user_sql = "select * from kboy_user where uid=$kboy_userid limit 1";

	$user_rows = mysql_query($user_sql);

	while($user_rs = mysql_fetch_array($user_rows)){

		$user_realname = $user_rs['user_realname'];
		
		$user_phone = $user_rs['user_phone'];

		$user_tel = $user_rs['user_tel'];
		
		$user_sex = $user_rs['user_sex'];
		$user_idcard = $user_rs['user_idcard'];
		if(empty($user_realname) || empty($user_idcard) || empty($user_phone) && empty($user_tel))
		{
			echo ok('请完善您的基本资料', 'user_basics.php');
		}

	}
	if(!empty($user_phone)){
		$order_phone=$user_phone;
	}else{
		$order_phone=$user_tel;
	}
	$sex = substr($user_idcard,-2,1);
		if($sex%2==0){
			$sex = 0;
		}else{
			$sex = 1;
		}
	$mysql = new sqlstr("kboy_order"); 

	$news_sql = $mysql -> deleteSql("uid=$kboy_userid and aid=$aid");

	mysql_query($news_sql);

	$mysql -> set("uid",$kboy_userid,true);
	$mysql -> set("order_phone",$order_phone);
	$mysql -> set("order_no",$order_no);
	$mysql -> set("order_realname",$user_realname);
	$mysql -> set("order_sex",$sex);
	$mysql -> set("order_shangche",$active_center);
	$mysql -> set("order_idcard",$user_idcard);
	//性别
//	$mysql -> set("order_shangche",$order_shangche);
	
	$mysql -> set("aid",$aid,true);

	$mysql -> set("order_num",1);
	
	$news_sql = $mysql -> insertSql();

	$news_res = mysql_query($news_sql);

	if($news_res){
		$active_all_money = getClassName("kboy_forum_active", "active_all_money","id = $aid");
		if($active_all_money != 0){
			echo "<script>if(!confirm('报名成功，前往支付，点击取消可以现场支付')){location.href='user_order.php'}</script>";
		}else{
			echo "<script>if(confirm('报名成功')){location.href='user_order.php'}</script>";
		}
		
	}else{
		echo erro("报名失败，请联系18514024178");
	}

	

	$active_all_money = getClassName("kboy_forum_active","active_all_money","id=$aid");

	$active_cva_money = getClassName("kboy_forum_active","active_cva_money","id=$aid");

	$user_style  = getClassName("kboy_user","user_style","uid=$kboy_userid");

	


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title><?= $web_titles ?></title>

<meta name="Keywords" content="<?= $web_keywords ?>" />

<meta name="Description" content="<?= $web_description ?>" />

<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />

<link rel="stylesheet" href="css/common.css"/>

<link rel="stylesheet" href="css/sq.css"/>

<script type="text/javascript" src="js/baidutongji.js"></script>
<style type="text/css">
	@media screen and (max-width:500px ) {
		.top-bar{
			display: none;
		}
		.order-top-tips{
			display: none;
		}
		.order-item .order-info .orderer-info{
			float: none;
		}
		.order-item .order-info .orderer-info .w1045{
			width: 250px;
		}
		.order-item .add-p{
			position: static;
		}
		.order-item .order-info .delete_p{
			position: static;
		}
		.payway_style .bank-name{
			width: 250px;
			height: auto;
			margin-left: 70px;
		}
		.order-post .order-submit{
			float: none;
		}
		.foot_wrap{
			display: none;
		}
		.order-item .o-title h3{
			float: none;
		}
		.order-item .order-detail{
			height: auto;
			margin-left: 50px;
		}
		.order-item .order-detail .order-num{
			float: none;
		}
		.order-item .order-detail .order-price{
			display: block;
			float: none;
		}
		.order-item .order-detail .order-pirce-op{
			display: block;
			margin: 0;
		}
		.order-item .o-title .tips{
			float: none;
		}
		.order-item .order-info .orderer-info span{
			min-width: 120px;
		}
		.header-wrap{
			display: none;
		}
		.search-box{
			display: none;
		}
		.order-box .order-step{
			margin-left: 50px;
		}
		.header-ss .top_ads{
			width: 100px;
    		height: 50px;
    		overflow: hidden;
        	margin-top: 35px;
		}
		.order-post .order-price-total{
			float: none;
			margin-bottom: 25px;
		}
		.order-post{
			height: auto;
		}
		.xianxia{
			margin-top: 10px;
			margin-left: 35px;
		}
		body{
			min-width: 100%;
		}
	}
</style>

<script type="text/javascript" src="js/laydate/laydate.js"></script>
</head>

<body>

    <!--top-bar begin-->

	<? include("_include.top.topbar.php") ?>

    <!--top-bar end-->

    <!--header begin-->

	<? include("_include.top.navbar.php") ?>

    <!--header end-->

   <div class="order-box">

       <div class="content">

           <div class="order-step"><i class="order-write"></i>填写订单</div>

           <div class="order-top-tips">

               <ul>

                   <li><i>1</i>我要报名</li>

                   <li class="cur"><i>2</i>填写订单</li>

                   <li><i>3</i>进行支付</li>

                   <li><i>4</i>支付完成</li>

               </ul>

           </div>

		   

		   <form method="post" action="ordersave.php?action=ordersave">

		   <input type="hidden" value="<?=$order_no?>" name="WIDout_trade_no" />

		   <input type="hidden" value="<?=$aid?>" name="aid" />

		   <input type="hidden" name="order_isfull" value="1" />

           <div class="order-bd-con">

               <div class="order-item">

                   <div class="o-title">

                       <h3>订单信息</h3>

                   </div>

                   <div class="order-detail">

                       <div class="order-num">订单编号：<span><?=$order_no?></span></div>

					   <?php if($active_all_money > 0){ ?>

                       <div class="order-price">订单金额：
                       		<span class="price on">￥<em><?php if($user_style==0){ echo $active_all_money;}else{ echo $active_cva_money;}?></em></span>
                       		<span class="price">￥<em><?=getClassName("kboy_forum_active","active_part_money","id=$aid")?></em></span>
                       		<div class="order-pirce-op">
                       			<a href="javascript:;" class="on">全款</a><a href="javascript:;">预付款</a>
                       		</div>
                       	</div>
						<label class="label_yd">

                              		<input type="radio" name="rWay1" value="1" style="opacity: 0">
                                
                              		<span class="bank-pic xianxia">现场付费</span>
                           			</label>
                       	<?php } ?>
                   </div>

               </div>

               <div class="order-item">

                   <div class="o-title">

                       <h3>下单人员信息</h3>

                       <p class="tips">您的个人资料将用于购买保险核对信息，请准确填写，我们将保护您的隐私。</p>

                   </div>

                   <div class="order-info-wrapper">

                       <div class="order-info">

                           <div class="orderer-info">

                               <span>客户姓名:</span>

                               <input type="text" class="input_wby1 o_right w134" value="<?=$user_realname?>" name="order_realname[]"/>

                           </div>

                           <div class="orderer-info">

                               <span>联系电话:</span>
								<?php if(!empty($user_phone)){ ?>
                               <input type="text" class="input_wby1 o_right w154" value="<?=$user_phone?>" name="order_phone[]"/>
								<?php }else{ ?>
								<input type="text" class="input_wby1 o_right w154" value="<?=$user_tel?>" name="order_phone[]"/>	
								<?php } ?>
                           </div>

                           <div class="orderer-info">

                               <!-- <span>名和身份证/护照号:</span> -->
                               <span>身份证/护照号:</span>

                               <input type="text" id="identity"  class="input_wby1 o_right w288" value="<?=$user_idcard?>" name="order_idcard[]"/>

                           </div>

                           <div class="orderer-info">

                                <span>上车地点:</span>

                               <input type="text" id="identity"  class="input_wby1 o_right w288" value="" name="order_shangche[]" placeholder="请输入上车地"/>

                           </div>

                           <div class="orderer-info nr">

                               <span>备注:</span>

                               <input type="text" class="input_wby1 w1045" value="" placeholder="请输入要备注的信息！注意性别" name="order_text[]"/>

                           </div>

                           <!--<div class="delete_p"><a href="javascript:;">删除</a></div>-->

                       </div>

                   </div>

                   <div class="add-p"><a href="javascript:;"><input type="button" id="bmr" value="添加报名人" /></a></div>
					
               </div>
				注：请务必填写真实姓名和身份证/护照等信息，否则保险无效。
			   

			   

               <div class="order-item">

                   <div class="o-title">

                       <h3>企业用户报名</h3>

                       <p class="tips"></p>

                   </div>

                   <div >

				   <?=$index_mk2?>

				   </div>

			   </div>

               <div class="order-item">

			   <?php if($active_all_money > 0){ ?>

                   <div class="o-title">

                       <h3>选择支付方式</h3>

                       <p class="tips">目前仅支持支付宝在线支付，其他支付方式正在完善中，尽请谅解。</p>

                   </div>

                   <div class="payway_style">

                       <div class="bank-name">

                           <label class="label_yd">

                               <input type="radio" name="rWay1" value="0" checked="checked">

                               <span class="bank-pic"><img src="images/zf_pic1.png" width="215" height="65" alt=""/></span>

                           </label>

                          <label class="label_yd">

                               <input type="radio" name="rWay1" value="2" checked="checked">

                               <span class="bank-pic"><img src="images/con41.png"/></span>

                           </label>

						   

                       </div>                       

                   </div>

				<?php } ?>   

				   

                   <div class="order-post">

				   <?php if($active_all_money > 0){ ?>

                       <div class="order-price-total">应付金额： <span>¥<em><?php if($user_style==0){ echo $active_all_money;}else{ echo $active_cva_money;}?></em></span></div><?php } ?>

                       <div class="order-submit"><input type="submit" value="提交订单" id="order-post" /></div>

                   </div>

               </div>

           </div>

		   </form>

       </div>

   </div>

    <!--foot begin-->

	<? include("_include.bottom.footbar.php") ?>

    <!--foot begin-->

    <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>

    <script type="text/javascript" src="js/jquery.SuperSlide.2.1.1.js"></script>

    <script type="text/javascript" src="js/main.js"></script>

    <script type="text/javascript" src="js/sq.js"></script>

    <script type="text/javascript" src="js/cropbox.js"></script>

    <script type="text/javascript" src="layer/layer.js"></script>
    

</body>

</html>
<script type="text/javascript">
	// 验证身份证 
				function isCardNo(card) { 
				 var pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; 
				 return pattern.test(card); 
				} 
			 // 验证身份证
			 $("#identity").blur(function(){
			 	if($('#identity').val().length == 0) { 
				  alert("请填写身份证");
				 } else {
				  if(isCardNo($('#identity').val()) == false) {
				   alert("身份证号不正确");
				  }
				 }
			 })
               $(".xianxia").click(function(){
                    $(this).css({"background":"#C30D23","color":"#fff"});
                    $(".order-pirce-op a").removeClass("on");
              })
				$(".bank-name").click(function(){
					$(".xianxia").css({"background":"#fff","color":"#454444"});
				})
				$(".order-pirce-op").click(function(){
					$(".xianxia").css({"background":"#fff","color":"#454444"});
				})
</script>
